package com.mfin.bs.mgr.impl;

import com.mfin.bs.mappers.factory.BaseMapperFactory;
import com.mfin.bs.mappers.factory.IMapperFactory;
import com.mfin.bs.mappers.interfaces.IMapper;
import com.mfin.log.Logger;
import com.mfin.persistence.IPersistenceGovernor;
import com.mfin.vo.interfaces.IMappable;

public abstract class BaseManager extends Logger {
	IMapperFactory mapperFactory = BaseMapperFactory.getInstance();
	IPersistenceGovernor persistence = null;

	public boolean map(IMappable fromArg, IMappable toArg,
			boolean validateKeys, boolean mapKeys) {

		boolean ableToMap = false;

		IMapper mapper = mapperFactory.getMapper(fromArg, toArg);

		if (fromArg != null && toArg != null) {
			ableToMap = mapper.map(fromArg, toArg, validateKeys, mapKeys);
		}

		return ableToMap;
	}

	public void setPersistenceGovernor(IPersistenceGovernor persistence) {
		this.persistence = persistence;
	}

	public IPersistenceGovernor getPersistenceGovernor() {
		return persistence;
	}
}
